package com.study.easyexcel.common.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;

import java.util.ArrayList;
import java.util.List;

/**
 * 说明书映射实体；用于导出模板的说明专用工作薄，一般无表头
 *
 * @author yuhuan
 * @date 2023/5/11
 */
@ContentRowHeight(20)
@ContentStyle(verticalAlignment = VerticalAlignmentEnum.CENTER)
public class Instructions {

    @ExcelProperty(index = 0)
    @ColumnWidth(8)
    private String code;

    @ExcelProperty(index = 1)
    private String explain;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getExplain() {
        return explain;
    }

    public void setExplain(String explain) {
        this.explain = explain;
    }

    public static List<Instructions> doc(List<String> templateDoc) {
        List<Instructions> docList = new ArrayList<>();
        for (int i = 0; i < templateDoc.size(); i++) {
            Instructions data = new Instructions();
            data.setCode(String.valueOf(i + 1));
            data.setExplain(templateDoc.get(i));
            docList.add(data);
        }
        return docList;
    }

    @Override
    public String toString() {
        return "Instructions{" +
                "code='" + code + '\'' +
                ", explain='" + explain + '\'' +
                '}';
    }
}
